<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>range改变背景颜色</title>
</head>
<body>
    <input type="range" max="255" min="0" value="0">
    <input type="range" max="255" min="0" value="0">
    <input type="range" max="255" min="0" value="0">
    <input type="range" max="1" min="0" value="1" step="0.1">
    <script>
        var rangeList = document.querySelectorAll("input[type=range]");
        for(var i = 0; i < rangeList.length; i++){
            rangeList[i].oninput = function(){
                document.body.style.backgroundColor = "rgba("+rangeList[0].value+","+rangeList[1].value+","+rangeList[2].value+","+rangeList[3].value+")";
            }
        }
    </script>
</body>
</html>
